function previewParse(txtArea, previewArea) {
	var txtNew = document.getElementById(txtArea).value;
	var txtArea = document.getElementById(txtArea);
	var previewArea = document.getElementById(previewArea);
	var smileyPath = 'media/smilies';
	var templatePath = 'media/icons';
	var scrollTop = txtArea.scrollTop;
	var scrollHeight = txtArea.scrollHeight;
	var previewScrollHeight = previewArea.scrollHeight;

	// Newline
	txtNew = txtNew.replace(/\n/g, '<br />');
	
	// Email
	//txtNew = txtNew.replace(/([a-z0-9\._-]+)@([a-z0-9\._-]+)\.+([a-z]{2,3})/ig, '$1 AT $2 DOT $3');

	// URL
	//txtNew = txtNew.replace(/([a-z0-9\._-]+\:\/\/[a-z0-9\._-]+\.+[a-z]{2,3})/ig, '<a href="$1" target="_blank">$1</a>');

	// BBcode
	txtNew = txtNew.replace(/\[url=([^<> \n]+?)\](.+?)\[\/url\]/ig, '<a href="$1" target="_blank">$2</a>');
	txtNew = txtNew.replace(/\[url\]([a-z0-9\._-]+\:\/\/[a-z0-9\._-]+\.+[a-z]{2,3})\[\/url\]/ig, '<a href="$1" target="_blank">$1</a>');
	txtNew = txtNew.replace(/\[quote=([^<> \n]+?)\](.+?)\[\/quote\]/ig, '<div class="quote"><b>$1:</b><br />$2</div>');
	txtNew = txtNew.replace(/\[quote\](.+?)\[\/quote\]/ig, '<div class="quote"><b>Quote:</b><br />$1</div>');
	txtNew = txtNew.replace(/\[code\](.+?)\[\/code\]/ig, '<div class="code"><b>Code:</b><br />$1</div>');
	txtNew = txtNew.replace(/\[email\]([a-z0-9\._-]+@[a-z0-9\._-]+\.+[a-z]{2,3})\[\/email\]/ig, '<a href="mailto:$1">$1</a>');
	txtNew = txtNew.replace(/\[img\](([^<> \n]+?)\.(png|jpg|jpeg|png|bmp))\[\/img\]/ig, '<img src="$1" border="0" alt="$1" />');
	txtNew = txtNew.replace(/\[b\](.+?)\[\/b\]/ig, '<b>$1</b>');
	txtNew = txtNew.replace(/\[i\](.+?)\[\/i\]/ig, '<i>$1</i>');
	txtNew = txtNew.replace(/\[u\](.+?)\[\/u\]/ig, '<u>$1</u>');
	txtNew = txtNew.replace(/\[s\](.+?)\[\/s\]/ig, '<s>$1</s>');
	txtNew = txtNew.replace(/\[h1\](.+?)\[\/h1\]/ig, '<h1>$1</h1>');
	txtNew = txtNew.replace(/\[h2\](.+?)\[\/h2\]/ig, '<h2>$1</h2>');
	txtNew = txtNew.replace(/\[h3\](.+?)\[\/h3\]/ig, '<h3>$1</h3>');
	txtNew = txtNew.replace(/\[hr\]/ig, '<div class="hr">&nbsp;</div>');
	txtNew = txtNew.replace(/\[center\](.+?)\[\/center\]/ig, '<center>$1</center>');
	txtNew = txtNew.replace(/\[align=(left|right|center|justify)?\](.+?)\[\/align\]/ig, '<div align="$1">$2</div>');
	txtNew = txtNew.replace(/\[colour=([#a-z0-9]+?)\](.+?)\[\/colour\]/ig, '<font color="$1">$2</font>');
	txtNew = txtNew.replace(/\[link=([^<> \n]+?)\](.+?)\[\/link\]/ig, '<a href="$1">$2</a>');
	txtNew = txtNew.replace(/\[bp\]/ig, '<img src="' + templatePath + '/bullet.png" alt="Bullet Point" align="middle" border="0" /> ');
	txtNew = txtNew.replace(/\[\*\]/ig, '<img src="' + templatePath + '/bullet.png" alt="Bullet Point" align="middle" border="0" /> ');		
	txtNew = txtNew.replace(/\[arrow\]/ig, '<img src="' + templatePath + '/arrow.png" alt="Arrow" align="middle" border="0" /> ');
	txtNew = txtNew.replace(/\[ab=([^<> \n].+?)\](.+?)\[\/ab\]/ig, '<abbr title="$1">$2</abbr>');
	txtNew = txtNew.replace(/\[indent\](.+?)\[\/indent\]/ig, '<div class="indent">$1</div>');
	txtNew = txtNew.replace(/\[html\](.+?)\[\/html\]/ig, '$1');

	// Smilies
	txtNew = txtNew.replace(/ 0:\)/ig, ' <img src="' + smileyPath + '/angel.png" alt="Angel" title="Angel" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ O:\)/ig, ' <img src="' + smileyPath + '/angel.png" alt="Angel" title="Angel" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ >:\(/ig, ' <img src="' + smileyPath + '/angry.png" alt="Angry" title="Angel" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ ->/ig, ' <img src="' + smileyPath + '/arrow.png" alt="Arrow" title="Arrow" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ =>/ig, ' <img src="' + smileyPath + '/arrow.png" alt="Arrow" title="Arrow" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :arrow:/ig, ' <img src="' + smileyPath + '/arrow.png" alt="Arrow" title="Arrow" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :P/ig, ' <img src="' + smileyPath + '/cheeky.png" alt="Cheeky" title="Cheeky" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :S/ig, ' <img src="' + smileyPath + '/confused.png" alt="Confused" title="Confused" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ B\)/ig, ' <img src="' + smileyPath + '/cool.png" alt="Cool" title="Cool" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ ;\(/ig, ' <img src="' + smileyPath + '/cry.png" alt="Cry" title="Cry" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :pp/ig, ' <img src="' + smileyPath + '/drool.png" alt="Drool" title="Drool" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ 8\|/ig, ' <img src="' + smileyPath + '/eek.png" alt="Eek!" title="Eek!" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :#/ig, ' <img src="' + smileyPath + '/embarrassed.png" alt="Embarrassed" title="Embarrassed" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ 0:\)/ig, ' <img src="' + smileyPath + '/evil.png" alt="Evil" title="Evil" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ 8:\)/ig, ' <img src="' + smileyPath + '/excited.png" alt="Excited!" title="Excited!" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ 0:\)/ig, ' <img src="' + smileyPath + '/exclaim.png" alt="Exclaim!" title="Exclaim!" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :D/ig, ' <img src="' + smileyPath + '/grin.png" alt="Grining" title="Grining" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :!/ig, ' <img src="' + smileyPath + '/idea.png" alt="Idea!" title="Idea!" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ lol/ig, ' <img src="' + smileyPath + '/laugh.png" alt="Laughing" title="Laughing" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :lol:/ig, ' <img src="' + smileyPath + '/laugh.png" alt="Laughing" title="Laughing" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :X/ig, ' <img src="' + smileyPath + '/lips_sealed.png" alt="My Lips are Sealed" title="My Lips are Sealed" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :L/ig, ' <img src="' + smileyPath + '/love.png" alt="Love" title="Love" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :M/ig, ' <img src="' + smileyPath + '/mad.png" alt="Mad" title="Mad" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :G/ig, ' <img src="' + smileyPath + '/mr_green.png" alt="Mr Green" title="Mr Green" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :\|/ig, ' <img src="' + smileyPath + '/neutral.png" alt="Neutral" title="Neutral" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :oops:/ig, ' <img src="' + smileyPath + '/oops.png" alt="Opps!" title="Opps!" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :\?/ig, ' <img src="' + smileyPath + '/question.png" alt="Question?" title="Question?" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :R/ig, ' <img src="' + smileyPath + '/rolleyes.png" alt="Rolling Eyes" title="Rolling Eyes" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :\(/ig, ' <img src="' + smileyPath + '/sad.png" alt="Sad" title="Sad" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :\)/ig, ' <img src="' + smileyPath + '/smile.png" alt="Smiling" title="Smiling" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :O/ig, ' <img src="' + smileyPath + '/surprised.png" alt="Surprised" title="Surprised" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :T/ig, ' <img src="' + smileyPath + '/thumbs_up.png" alt="Thumbs Up!" title="Thumbs Up!" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ :twisted:/ig, ' <img src="' + smileyPath + '/twisted.png" alt="Twisted" title="Twisted" align="middle" border="0"> ');
	txtNew = txtNew.replace(/ ;\)/ig, ' <img src="' + smileyPath + '/wink.png" alt="Winking" title="Winking" align="middle" border="0"> ');

	previewArea.innerHTML = txtNew;
	previewArea.scrollTop = scrollTop * (previewScrollHeight + 0.1 / scrollHeight);
}